
* Set the working directory to a folder that contains both datasets.

*** Main findings ***
***Table 2 
**PRIO dataset
use PRIO_casualties, clear
xtset ccode ts
xtreg pervote1 c.diffongoingdead##c.govt_rile##i.leader lagpervote1 enep lnten1 ciepmonth gparties parldum1 endconflict ongoingconflict unemploy inflationyr, re robust
eststo Model1
xtreg pervote1 c.diffongoingdead##c.govt_rile##i.leader lagpervote1 enep lnten1 ciepmonth gparties parldum1 endconflict ongoingconflict unemploy inflationyr i.ccode, robust 
eststo Model2

**MID datset 
use Election and casualty data, clear
xtset ccode edate
xtreg pervote c.diffmedium_cas##c.rile##i.culpable prepervote numparties lnten1 ciepmonth gparties parldum totalfatalmids ongoingfatalmids lagunemploy laginflation, re robust
eststo Model1
xtreg pervote c.diffmedium_cas##c.rile##i.culpable prepervote numparties lnten1 ciepmonth gparties parldum totalfatalmids ongoingfatalmids lagunemploy laginflation i.ccode, vce(robust)
eststo Model2

esttab using table1.tex, replace label se nodepvars ///
star(+ 0.10 * 0.05 ** .01 *** .001) stats(fixed N r2_o, label("Country Effects" "N Obs." "Overall $R^2$")) drop (*ccode) nogaps ///
title(Regression analysis of casualties and incumbent vote share ///
\label{reg1})

**Figure 2 (left) 
use PRIO_casualties, clear
xtset ccode ts
xtreg pervote1 c.diffongoingdead##c.govt_rile##i.leader lagpervote1 enep lnten1 ciepmonth gparties parldum1 endconflict ongoingconflict unemploy inflationyr, re robust cluster(ccode)
margins, dydx(diffongoingdead) at(govt_rile==(-60 (10) 60) leader==(0 1)) level(95)
marginsplot

**Figure 2 (right) 
use Election and casualty data, clear
xtset ccode edate
xtreg pervote c.diffmedium_cas##c.rile##i.culpable prepervote enep lnten1 ciepmonth gparties parldum totalfatalmids ongoingfatalmids lagunemploy laginflation, re robust
margins, dydx(diffmedium_cas) at(rile==(-60 (10) 60) culpable==(0 1))
marginsplot
